﻿using System.Windows;
using System.Windows.Controls;
using ImageAppViewModels;

namespace WpfImageDuplicates
{
    /// <summary>
    /// Interaction logic for EventCallInfoView.xaml
    /// </summary>
    public partial class EventCallInfoView : UserControl
    {
        public EventCallInfoView()
        {
            InitializeComponent();            
        }

        public static readonly DependencyProperty EventCallInfoViewModelProperty =
            DependencyProperty.Register("EventCallInfoViewModel", typeof(EventCallInfoViewModel), typeof(EventCallInfoView), new PropertyMetadata(null, OnEventCallInfoViewModelPropertyChanged));

        public EventCallInfoViewModel EventCallInfoViewModel
        {
            get { return (EventCallInfoViewModel)GetValue(EventCallInfoViewModelProperty); }
            set { SetValue(EventCallInfoViewModelProperty, value); }
        }

        private static void OnEventCallInfoViewModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EventCallInfoView source = d as EventCallInfoView;
            source.UpdateEventCallInfoViewModel(e.NewValue as EventCallInfoViewModel, e.OldValue as EventCallInfoViewModel);
        }

        public void UpdateEventCallInfoViewModel(EventCallInfoViewModel viewModel, EventCallInfoViewModel viewModelOld)
        {
            EventCallInfoViewModel = viewModel;
            this.DataContext = EventCallInfoViewModel;
        }
    }
}
